﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PlayController : MonoBehaviour
{
	private Rigidbody rb;
	public Vector3 newPosition;
	public TextMesh scoreMesh;
	public Text score;
	public int record;
	// Use this for initialization
	void Start ()
	{
		record = 0;
		rb = GetComponent<Rigidbody> ();
		newPosition = new Vector3 ();
	}
	
	// Update is called once per frame
	void Update ()
	{
	
	}

	void FixedUpdate ()
	{
		float moveH = Input.GetAxis ("Horizontal");
		float moveV = Input.GetAxis ("Vertical");

		Vector3 direction = new Vector3 (moveH, 0, moveV);
		Vector3 force = direction * 5;

		rb.AddForce (force);

	}

	void OnTriggerEnter (Collider collider)
	{
		//collider.gameObject.SetActive (false);
		Destroy (collider.gameObject);
		record = record + 1;
		score.text = record.ToString ();
		scoreMesh.text = record.ToString ();
	}
}
